package com.ncr.travel.appmgr.service.config;

import java.util.Date;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Random;
import java.util.Set;
import java.util.UUID;

import javax.annotation.PostConstruct;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;

import com.ncr.travel.appmgr.model.ErrorTextJson;
import com.ncr.travel.appmgr.model.TextEntryJson;
import com.ncr.travel.appmgr.model.shared.Alignment;
import com.ncr.travel.appmgr.model.shared.Category;
import com.ncr.travel.tas.configuration.dao.ConfigurationDao;
import com.ncr.travel.tas.configuration.model.ConfigurationNode;
import com.ncr.travel.tas.configuration.model.ConfigurationValue;
import com.ncr.travel.tas.configuration.model.TableColumn;
import com.ncr.travel.tas.configuration.model.TableRow;
import com.ncr.travel.tas.configuration.model.TableValue;
import com.ncr.travel.tas.shared.configuration.ConfigurationKey;
import com.ncr.travel.tas.shared.configuration.ConfigurationNodeEnum;
import com.ncr.travel.tas.shared.configuration.ConfigurationProductKey;
import com.ncr.travel.tas.shared.configuration.ConfigurationValueEnum;

@Component
public class AppManagerConfigurationNodeBuilder {

	private ConfigurationDao configurationDao;

	@Autowired
	@Qualifier("configurationDao")
	public void setConfigurationDao(ConfigurationDao nodeRepository) {
		this.configurationDao = nodeRepository;
	}

	@PostConstruct
	public void initialize() {
		createProductConfiguration();
	}

	public void createProductConfiguration() {
		ConfigurationNode applicationManagerNode = new ConfigurationNode(ConfigurationNodeEnum.APPMGR);
		String author = AppManagerConfigurationNodeBuilder.class.getCanonicalName();
		applicationManagerNode.setName(ConfigurationProductKey.APPLICATION_MANAGER_UI);
		applicationManagerNode.setDescription("Application Manager UI Settings");
		applicationManagerNode.setUpdatedBy(author);
		applicationManagerNode.setUpdatedOn(new Date());

		// create the products right underneath
		ConfigurationValue productKeys = createProducts();
		applicationManagerNode.addConfiguration(productKeys);

		configurationDao.save(applicationManagerNode);
	}

	public static ConfigurationValue createProducts() {

		ConfigurationValue productList = new ConfigurationValue(ConfigurationKey.PRODUCTS, ConfigurationValueEnum.LIST,
				"Products");

		createKioskProduct(productList);

		createWebProduct(productList);

		createReservationProduct(productList);

		createBagDropProduct(productList);

		createGlobalProduct(productList);

		return productList;
	}

	private static void createGlobalProduct(ConfigurationValue productList) {
		ConfigurationValue global = new ConfigurationValue(ConfigurationProductKey.SHARED,
				UUID.randomUUID().toString(), "Global");
		productList.addChildValue(global);
	}

	private static void createBagDropProduct(ConfigurationValue productList) {
		ConfigurationValue bagdrop = new ConfigurationValue(ConfigurationProductKey.BAG_DROP, UUID.randomUUID()
				.toString(), "Bag Drop");
		productList.addChildValue(bagdrop);
	}

	private static void createReservationProduct(ConfigurationValue productList) {
		ConfigurationValue ticketing = new ConfigurationValue(ConfigurationProductKey.RESERVATION_TICKETING, UUID
				.randomUUID().toString(), "Ticketing");
		productList.addChildValue(ticketing);
	}

	private static void createWebProduct(ConfigurationValue productList) {
		ConfigurationValue web = new ConfigurationValue(ConfigurationProductKey.WEB_CHECKIN, UUID.randomUUID()
				.toString(), "Web Check-in");
		addWebCategoriesAndScreens(web);
		productList.addChildValue(web);
	}

	private static void createKioskProduct(ConfigurationValue productList) {
		ConfigurationValue kiosk = new ConfigurationValue(ConfigurationProductKey.KIOSK_CHECKIN, UUID.randomUUID()
				.toString(), "Kiosk Check-in");
		addKioskCategoriesAndScreens(kiosk);
		productList.addChildValue(kiosk);
	}

	private static void addKioskCategoriesAndScreens(ConfigurationValue kiosk) {

		addGlobalCategoryScreens(kiosk);
		addBaseAppAndScreens(kiosk);
		addFinalAdviceScreens(kiosk);
		addBoardingPassPrintScreens(kiosk);
		addSelfBagTaggingScreens(kiosk);
		addContactInformationScreens(kiosk);
		addOverSoldSolicitationScreens(kiosk);
		addFlightInterruptionAtCheckInScreens(kiosk);
	}

	private static void addFlightInterruptionAtCheckInScreens(ConfigurationValue kiosk) {

		ConfigurationValue category = new ConfigurationValue("FlightInterruptionAtCheckIn", true, "Flight Interruption");
		kiosk.addChildValue(category);

		// add screens to category
		ConfigurationValue screen = new ConfigurationValue("BaseFunctionality", true, "Base Functionality");
		category.addChildValue(screen);

		screen = new ConfigurationValue("FlightOptions", true, "Flight Options");
		category.addChildValue(screen);

		screen = new ConfigurationValue("FlightCompensation", true, "Flight Compensation");
		category.addChildValue(screen);

		screen = new ConfigurationValue("VoucherPrinting", true, "Voucher Printing");
		category.addChildValue(screen);
	}

	private static void addOverSoldSolicitationScreens(ConfigurationValue kiosk) {

		ConfigurationValue category = new ConfigurationValue("OversoldSolicitation", true, "Oversold Solicitation");
		kiosk.addChildValue(category);

		// add screens to category
		ConfigurationValue screen = new ConfigurationValue("BaseFunctionality", true, "Base Functionality");
		category.addChildValue(screen);

		screen = new ConfigurationValue("OversoldAdvisoryMessage", true, "Oversold Advisory Message");
		category.addChildValue(screen);
	}

	private static void addContactInformationScreens(ConfigurationValue kiosk) {

		ConfigurationValue category = new ConfigurationValue("ContactInformation", true, "Contact Information");
		kiosk.addChildValue(category);

		// add screens to category
		ConfigurationValue screen = new ConfigurationValue("BaseFunctionality", true, "Base Functionality");
		category.addChildValue(screen);

		screen = new ConfigurationValue("ContactDataCollection", true, "Contact Data Collection");
		category.addChildValue(screen);
	}

	private static void addReEntrySDRTripSelectionScreens(ConfigurationValue kiosk) {

		ConfigurationValue category = new ConfigurationValue("ReEntryAndSdrTripSelection", true,
				"Re-entry and SDR Trip Selection");
		kiosk.addChildValue(category);
	}

	private static void addReEntryPassengerScreens(ConfigurationValue kiosk) {

		ConfigurationValue category = new ConfigurationValue("ReEntryPassengerSelection", true,
				"Re-entry Passenger Selection");
		kiosk.addChildValue(category);
	}

	private static void addSameDayReturnScreens(ConfigurationValue kiosk) {

		ConfigurationValue category = new ConfigurationValue("SameDayReturnScreens", true, "Same Day Return Screens");
		kiosk.addChildValue(category);

		// add screens to category
		ConfigurationValue screen = new ConfigurationValue("SameDayReturnThankYou", true, "Same Day Return Thank You");
		category.addChildValue(screen);

		ConfigurationValue subscreen = new ConfigurationValue("SameDayReturnThankYouOption1", true,
				"Same Day Return Thank You Option 1");
		screen.addChildValue(subscreen);

		screen = new ConfigurationValue("SameDayReturnThankYouStep2", true, "Same Day Return Thank You Step 2");
		screen.addChildValue(subscreen);
	}

	private static void addSelfBagTaggingScreens(ConfigurationValue kiosk) {
		ConfigurationValue category = new ConfigurationValue("SelfBagTaggingScreens", true, "Self Bag Tagging Screens");
		kiosk.addChildValue(category);
	}

	private static void addBoardingPassPrintScreens(ConfigurationValue kiosk) {
		ConfigurationValue category = new ConfigurationValue("BoardingPassPrint", true, "Boarding Pass Print");
		kiosk.addChildValue(category);
	}

	private static void addInfoScreens(ConfigurationValue kiosk) {

		ConfigurationValue category = new ConfigurationValue("InfoScreens", true, "Info Screens");
		kiosk.addChildValue(category);

		// add screens to category
		ConfigurationValue screen = new ConfigurationValue("InfoScreen1", true, "Info Screen 1");
		category.addChildValue(screen);

		screen = new ConfigurationValue("InfoScreen2", true, "Info Screen 2");
		category.addChildValue(screen);

		screen = new ConfigurationValue("InfoScreen3", true, "Info Screen 3");
		category.addChildValue(screen);

		screen = new ConfigurationValue("InfoScreen4", true, "Info Screen 4");
		category.addChildValue(screen);

		screen = new ConfigurationValue("InfoScreen5", true, "Info Screen 5");
		category.addChildValue(screen);
	}

	private static void addThankYouScreens(ConfigurationValue kiosk) {

		ConfigurationValue category = new ConfigurationValue("ThankYouScreen", true, "Thank You Screen");
		kiosk.addChildValue(category);

		// add screens to category
		ConfigurationValue screen = new ConfigurationValue(
				"ThankYou-1",
				"http://153.71.90.109:8080/application-manager-service/kioskCheck-In?themeUUID=2290af2a-44b8-4c82-b63f-97314aa1d9ef&path=BaseCheckInApp&ThankYouScreen&ThankYou-1",
				"Thank You-1");
		addThankYou1ScreenText(screen);
		category.addChildValue(screen);

		screen = new ConfigurationValue("ThankYou-2", true, "Thank You-2");
		category.addChildValue(screen);

		screen = new ConfigurationValue("ThankYou-3", true, "Thank You-2");
		category.addChildValue(screen);
	}

	private static void addThankYou1ScreenText(ConfigurationValue screenCV) {
		ConfigurationValue attractText = new ConfigurationValue(ConfigurationKey.TEXT, true, "ThankYou-1");
		screenCV.addChildValue(attractText);

		// thankyou
		ConfigurationValue thankYou = new ConfigurationValue("text.thankyou", "Thank you for flying with us!",
				"text.welcome");
		thankYou.setObjectType(TextEntryJson.class.getName());
		ConfigurationValue fontOptions = createFontOptionValues("Italic", 11, "#FCF86F", Alignment.JUSTIFY);
		Set<ConfigurationValue> childValues = createScreenChildValues(Category.LABEL, false, fontOptions);
		thankYou.setChildValues(childValues);
		attractText.addChildValue(thankYou);

		// checkInFor
		ConfigurationValue checkInFor = new ConfigurationValue("text.checkInFor", "You are now checkedin for:",
				"text.checkInFor");
		checkInFor.setObjectType(TextEntryJson.class.getName());
		fontOptions = createFontOptionValues("Bold", 12, "#5778CA", Alignment.LEFT);
		childValues = createScreenChildValues(Category.LABEL, true, fontOptions);
		checkInFor.setChildValues(childValues);
		attractText.addChildValue(checkInFor);

		// wait
		ConfigurationValue wait = new ConfigurationValue("text.wait",
				"Please wait while we print your boarding documents and receipts (Printing 2 of 4 item(s))",
				"text.wait");
		wait.setObjectType(TextEntryJson.class.getName());
		fontOptions = createFontOptionValues("Underline", 10, "#FBF304", Alignment.CENTER);
		childValues = createScreenChildValues(Category.LABEL, false, fontOptions);
		wait.setChildValues(childValues);
		attractText.addChildValue(wait);
	}

	private static void addFinalAdviceScreens(ConfigurationValue kiosk) {

		ConfigurationValue category = new ConfigurationValue("AdviceToPassenger", true, "Advice To Passenger");
		kiosk.addChildValue(category);
	}

	private static void addFinalCheckIn(ConfigurationValue kiosk) {

		ConfigurationValue category = new ConfigurationValue("FinalCheckIn", true, "Final Check-In");
		kiosk.addChildValue(category);

		// add screens to category
		ConfigurationValue screen = new ConfigurationValue("ThankYou1", true, "Thank You 1");
		category.addChildValue(screen);

		screen = new ConfigurationValue("ThankYou2", true, "Thank You 2");
		category.addChildValue(screen);

		screen = new ConfigurationValue("ThankYou3", true, "Thank You 3");
		category.addChildValue(screen);

		screen = new ConfigurationValue("ThankYou4", true, "Thank You 4");
		category.addChildValue(screen);

		screen = new ConfigurationValue("PrintTicketReceipt", true, "Print Ticket Receipt");
		category.addChildValue(screen);
	}

	private static void addBaggageScreens(ConfigurationValue kiosk) {

		ConfigurationValue category = new ConfigurationValue("Baggage", true, "Baggage");
		kiosk.addChildValue(category);

		// add screens to category
		ConfigurationValue screen = new ConfigurationValue("BaggageCheckIn", true, "Baggage Check-In");
		category.addChildValue(screen);

		screen = new ConfigurationValue("SpecialItems", true, "Special Items");
		category.addChildValue(screen);

		screen = new ConfigurationValue("BaggageWeightScale", true, "Baggage Weight Scale");
		category.addChildValue(screen);

		screen = new ConfigurationValue("BaggageWeightAdvisory", true, "Baggage Weight Advisory");
		category.addChildValue(screen);

		screen = new ConfigurationValue("BaggageSecurityQuestions", true, "Baggage Security Questions");
		category.addChildValue(screen);

		screen = new ConfigurationValue("DangerousGoods", true, "Dangerous Goods");
		category.addChildValue(screen);

		screen = new ConfigurationValue("Self Bag Tagging", true, "Self Bag Tagging");
		category.addChildValue(screen);
	}

	private static void addSeatAssignment(ConfigurationValue kiosk) {

		ConfigurationValue category = new ConfigurationValue("SeatAssignment", true, "Seat Assignment");
		kiosk.addChildValue(category);
	}

	private static void addSecureFlight(ConfigurationValue kiosk) {

		ConfigurationValue category = new ConfigurationValue("SecureFlight", true, "Secure Flight");
		kiosk.addChildValue(category);

		// add screens to category
		ConfigurationValue screen = new ConfigurationValue("SecureFlightDataEntry", true, "Secure Flight Data Entry");
		category.addChildValue(screen);

		screen = new ConfigurationValue("SecureFlightDataReview", true, "Secure Flight Data Review");
		category.addChildValue(screen);

		screen = new ConfigurationValue("SecureFlightPrivacyNotice", true, "Secure Flight Privacy Notice");
		category.addChildValue(screen);
	}

	private static void addBaseAppAndScreens(ConfigurationValue kiosk) {

		ConfigurationValue category = new ConfigurationValue("BaseCheckInApp", true, "Base Check-In App");
		kiosk.addChildValue(category);

		// add screens to category
		ConfigurationValue screen = new ConfigurationValue("AdminScreen", true, "Admin Screen");
		category.addChildValue(screen);

		screen = new ConfigurationValue(
				"AttractScreen",
				"http://153.71.90.109:8080/application-manager-service/kioskCheck-In?themeUUID=2290af2a-44b8-4c82-b63f-97314aa1d9ef&path=BaseCheckInApp&AttractScreen",
				"Attract Screen");
		addAttractScreenText(screen);
		category.addChildValue(screen);

		screen = new ConfigurationValue(
				"FindByOptions",
				"http://153.71.90.109:8080/application-manager-service/kioskCheck-In?themeUUID=2290af2a-44b8-4c82-b63f-97314aa1d9ef&path=BaseCheckInApp&FindByOptions",
				"Find By Screen");
		category.addChildValue(screen);
		addFindByText(screen);
		// addFindByGraphics(screen);
		addFindByFunctions(screen);
		// addFindByRules(screen);

		// select passenger screen
		screen = new ConfigurationValue("SelectPassenger", true, "Select Passenger");
		category.addChildValue(screen);
		// addMileagePlanRule(screen);

		ConfigurationValue childScreen = new ConfigurationValue("AddMileagePlan", true, "Add Mileage Plan");
		screen.addChildValue(childScreen);
		// addMileagePlanText(screen);
		// addMileagePlanGraphics(screen);
		addMileagePlanFunctions(screen, childScreen);
		addMileagePlanRules(screen, childScreen);

		childScreen = new ConfigurationValue("AddInfant", true, "Add Infant");
		screen.addChildValue(childScreen);

		childScreen = new ConfigurationValue("SelectAdultWithInfant", true, "Select Adult with Infant");
		screen.addChildValue(childScreen);

		childScreen = new ConfigurationValue("SpecialServiceRequestsCode", true, "Special Service Requests Code");
		screen.addChildValue(childScreen);

		childScreen = new ConfigurationValue("ArrivalCities", true, "Arrival Cities");
		screen.addChildValue(childScreen);

		addSecureFlight(category);
		addSeatAssignment(category);
		addBaggageScreens(category);
		addFinalCheckIn(category);
		addSameDayReturnScreens(category);
		addReEntryPassengerScreens(category);
		addReEntrySDRTripSelectionScreens(category);
		addInfoScreens(category);
		addThankYouScreens(category);
	}

	/**
	 * @param screen
	 * @deprecated
	 * @see addMileagePlanRules(ConfigurationValue value, ConfigurationValue
	 *      value)
	 */
	private static void addMileagePlanRule(ConfigurationValue screen) {

		ConfigurationValue rulesRoot = new ConfigurationValue(ConfigurationKey.RULES, true,
				"Select Passenger Screen Rules");
		screen.addChildValue(rulesRoot);

		// create the mileage plan rule root
		ConfigurationValue mileagePlanRule = new ConfigurationValue("MileagePlan", ConfigurationValueEnum.CONTROL);
		rulesRoot.addChildValue(mileagePlanRule);

		// we will now add rows for the mileage plan control. Note that the
		// attributes for each row
		// are added underneath a parent root. You will need to dig it back out
		// the same way.

		// attach the control's header
		ConfigurationValue header = new ConfigurationValue("Header", ConfigurationValueEnum.LIST);
		header.addChildValue(new ConfigurationValue("Column1", "Mileage Plan Program", "Mileage Plan Program"));
		header.addChildValue(new ConfigurationValue("Column2", "Mileage Plan Code", "Mileage Plan Code"));
		header.addChildValue(new ConfigurationValue("Column3", "Allowed For Mileage Credit",
				"Allowed For Mileage Credit"));
		header.addChildValue(new ConfigurationValue("Column4", "Show Airline Name", "Show Airline Name"));
		mileagePlanRule.addChildValue(header);

		// attach control row 1
		ConfigurationValue row1 = new ConfigurationValue("Row", ConfigurationValueEnum.LIST);
		row1.addChildValue(new ConfigurationValue("airline", "Alaska Airlines", "Airline"));
		row1.addChildValue(new ConfigurationValue("planCode", "AK", "Mileage Plan Code"));
		row1.addChildValue(new ConfigurationValue("allowedForCredit", "true", "Allowed For Credit"));
		row1.addChildValue(new ConfigurationValue("showAirlineName", "true", "Show Airline Name"));
		mileagePlanRule.addChildValue(row1);

		// attach control row 2
		ConfigurationValue row2 = new ConfigurationValue("Row", ConfigurationValueEnum.LIST);
		row1.addChildValue(new ConfigurationValue("airline", "American Airlines", "Airline"));
		row1.addChildValue(new ConfigurationValue("planCode", "AA", "Mileage Plan Code"));
		row1.addChildValue(new ConfigurationValue("allowedForCredit", "true", "Allowed For Credit"));
		row1.addChildValue(new ConfigurationValue("showAirlineName", "true", "Show Airline Name"));
		mileagePlanRule.addChildValue(row2);

		// attach control row 3
		ConfigurationValue row3 = new ConfigurationValue("Row", ConfigurationValueEnum.LIST);
		row1.addChildValue(new ConfigurationValue("airline", "British Airlines", "Airline"));
		row1.addChildValue(new ConfigurationValue("planCode", "BA", "Mileage Plan Code"));
		row1.addChildValue(new ConfigurationValue("allowedForCredit", "true", "Allowed For Credit"));
		row1.addChildValue(new ConfigurationValue("showAirlineName", "true", "Show Airline Name"));
		mileagePlanRule.addChildValue(row3);
	}

	private static void addAttractScreenText(ConfigurationValue screenCV) {
		ConfigurationValue attractText = new ConfigurationValue(ConfigurationKey.TEXT, true, "Attract");
		screenCV.addChildValue(attractText);

		// welcome
		ConfigurationValue welcome = new ConfigurationValue("text.welcome",
				"Welcome to our self-service check-in kiosk", "text.welcome");
		welcome.setObjectType(TextEntryJson.class.getName());
		ConfigurationValue fontOptions = createFontOptionValues("Bold", 12, "#5778CA", Alignment.LEFT);
		Set<ConfigurationValue> childValues = createScreenChildValues(Category.LABEL, false, fontOptions);
		welcome.setChildValues(childValues);
		attractText.addChildValue(welcome);

		// start
		ConfigurationValue start = new ConfigurationValue("text.start", "Start Check in", "text.start");
		start.setObjectType(TextEntryJson.class.getName());
		fontOptions = createFontOptionValues("Default", 14, "#ACE3FC", Alignment.RIGHT);
		childValues = createScreenChildValues(Category.BUTTON, false, fontOptions);
		start.setChildValues(childValues);
		attractText.addChildValue(start);

		// language
		ConfigurationValue language = new ConfigurationValue("text.language", "Spanish", "text.language");
		language.setObjectType(TextEntryJson.class.getName());
		fontOptions = createFontOptionValues("Italic", 11, "#FCF86F", Alignment.JUSTIFY);
		childValues = createScreenChildValues(Category.BUTTON, false, fontOptions);
		language.setChildValues(childValues);
		attractText.addChildValue(language);
	}

	private static void addCheckInScreenText(ConfigurationValue screenCV) {

		ConfigurationValue checkInText = new ConfigurationValue(ConfigurationKey.TEXT, true, "Check-In");
		screenCV.addChildValue(checkInText);

		// errorText 300
		ConfigurationValue errorText_300 = new ConfigurationValue("300", "Check In Failed.");
		errorText_300.setObjectType(ErrorTextJson.class.getName());
		ConfigurationValue fontOptions = createFontOptionValues("Bold", 12, "#5778CA", Alignment.LEFT);
		Set<ConfigurationValue> childValues = createScreenChildValues(Category.LABEL, false, fontOptions);
		errorText_300.setChildValues(childValues);
		checkInText.addChildValue(errorText_300);

		// errorText 301
		ConfigurationValue errorText_301 = new ConfigurationValue("301",
				"There are too many bags on the PNR to check-in.");
		errorText_301.setObjectType(ErrorTextJson.class.getName());
		fontOptions = createFontOptionValues("Default", 14, "#ACE3FC", Alignment.RIGHT);
		childValues = createScreenChildValues(Category.LABEL, false, fontOptions);
		errorText_301.setChildValues(childValues);
		checkInText.addChildValue(errorText_301);

		// errorText 302
		ConfigurationValue errorText_302 = new ConfigurationValue("302", "Unable to add bags to the PNR.");
		errorText_302.setObjectType(ErrorTextJson.class.getName());
		fontOptions = createFontOptionValues("Italic", 11, "#FCF86F", Alignment.JUSTIFY);
		childValues = createScreenChildValues(Category.LABEL, false, fontOptions);
		errorText_302.setChildValues(childValues);
		checkInText.addChildValue(errorText_302);

		// errorText 303
		ConfigurationValue errorText_303 = new ConfigurationValue("303",
				"There are too many bags on the PNR to check-in.");
		errorText_303.setObjectType(ErrorTextJson.class.getName());
		fontOptions = createFontOptionValues("Underline", 10, "#7891F5", Alignment.CENTER);
		childValues = createScreenChildValues(Category.LABEL, false, fontOptions);
		errorText_303.setChildValues(childValues);
		checkInText.addChildValue(errorText_303);

	}

	private static Set<ConfigurationValue> createScreenChildValues(Category category, boolean multiLine,
			ConfigurationValue fontOptionsCV) {
		Set<ConfigurationValue> childValues = new HashSet<ConfigurationValue>();
		ConfigurationValue txtCategoryCV = new ConfigurationValue("Category", category.name(), "Category");
		ConfigurationValue multiLineCV = new ConfigurationValue("MultiLine", multiLine, "MultiLine");
		childValues.add(txtCategoryCV);
		childValues.add(multiLineCV);
		childValues.add(fontOptionsCV);
		return childValues;

	}

	private static void addFindByText(ConfigurationValue screen) {

		ConfigurationValue findByOptions = new ConfigurationValue(ConfigurationKey.TEXT, true, "Find By Text Options");
		screen.addChildValue(findByOptions);

		// find by card/////////////////////////////////
		ConfigurationValue findByCard = new ConfigurationValue("FindByCard", "Swipe any Card", "Card");
		findByCard.setObjectType(TextEntryJson.class.getName());
		ConfigurationValue fontOptions = createFontOptionValues("Arial", 10, "#2E0854", Alignment.CENTER);
		Set<ConfigurationValue> childValues = createScreenChildValues(Category.LABEL, false, fontOptions);
		findByCard.setChildValues(childValues);
		findByOptions.addChildValue(findByCard);

		// /////////////////////////////////////////////

		// find by mileage number
		ConfigurationValue findByMileage = new ConfigurationValue("FindByMileage", "Frequent Fliers Club", "Loyalty");
		findByMileage.setObjectType(TextEntryJson.class.getName());
		fontOptions = createFontOptionValues("Arial", 10, "#2E0854", Alignment.CENTER);
		childValues = createScreenChildValues(Category.LABEL, false, fontOptions);
		findByMileage.setChildValues(childValues);
		findByOptions.addChildValue(findByMileage);

		// find by
		ConfigurationValue findByEtk = new ConfigurationValue("FindByETicket", "Paper Barcode", "E-Ticket");
		findByEtk.setObjectType(TextEntryJson.class.getName());
		fontOptions = createFontOptionValues("Arial", 10, "#2E0854", Alignment.CENTER);
		childValues = createScreenChildValues(Category.LABEL, false, fontOptions);
		findByEtk.setChildValues(childValues);
		findByOptions.addChildValue(findByEtk);

		// find by PNR
		ConfigurationValue findByPnr = new ConfigurationValue("FindByPnr", "Enter Reservation Number", "PNR");
		findByPnr.setObjectType(TextEntryJson.class.getName());
		fontOptions = createFontOptionValues("Arial", 10, "#2E0854", Alignment.CENTER);
		childValues = createScreenChildValues(Category.LABEL, false, fontOptions);
		findByPnr.setChildValues(childValues);
		findByOptions.addChildValue(findByPnr);

		// find by Confirmation Number
		ConfigurationValue findByConf = new ConfigurationValue("FindByConfirmationNumber", "Enter Confirmation Number",
				"Confirmation Number");
		findByConf.setObjectType(TextEntryJson.class.getName());
		fontOptions = createFontOptionValues("Arial", 10, "#2E0854", Alignment.CENTER);
		childValues = createScreenChildValues(Category.LABEL, false, fontOptions);
		findByConf.setChildValues(childValues);
		findByOptions.addChildValue(findByConf);

		// find by Passport
		ConfigurationValue findByPassport = new ConfigurationValue("FindByPassport", "Swipe Your Passport", "Passport");
		findByPassport.setObjectType(TextEntryJson.class.getName());
		findByPassport.setChildValues(childValues);
		fontOptions = createFontOptionValues("Arial", 10, "#2E0854", Alignment.CENTER);
		childValues = createScreenChildValues(Category.LABEL, false, fontOptions);
		findByOptions.addChildValue(findByPassport);

		// find by destination number
		ConfigurationValue findByDestination = new ConfigurationValue("FindByDestination",
				"Enter your destination city", "Destination");
		findByDestination.setObjectType(TextEntryJson.class.getName());
		fontOptions = createFontOptionValues("Arial", 10, "#2E0854", Alignment.CENTER);
		childValues = createScreenChildValues(Category.LABEL, false, fontOptions);
		findByDestination.setChildValues(childValues);
		findByOptions.addChildValue(findByDestination);

	}

	private static ConfigurationValue createFontOptionValues(String style, int size, String hexColor,
			Alignment alignment) {

		Set<ConfigurationValue> options = new HashSet<ConfigurationValue>();

		ConfigurationValue fStyle = new ConfigurationValue("Style", style, "Font Style");
		ConfigurationValue fsize = new ConfigurationValue("Size", size, "Font Size");
		ConfigurationValue fhexColor = new ConfigurationValue("Color", hexColor, "Font Color");
		ConfigurationValue falignment = new ConfigurationValue("Alignment", alignment.name(), "Alignment");

		options.add(fStyle);
		options.add(fsize);
		options.add(fhexColor);
		options.add(falignment);

		ConfigurationValue r = new ConfigurationValue("FontOptionsJson", true, "Font Options");
		r.setChildValues(options);

		return r;
	}

	private static void addFindByFunctions(ConfigurationValue screen) {

		ConfigurationValue findByOptions = new ConfigurationValue(ConfigurationKey.FUNCTIONS, true, "Find By Options");
		screen.addChildValue(findByOptions);

		// find by card
		ConfigurationValue findByCard = new ConfigurationValue("FindByCard", true, "Card");
		findByOptions.addChildValue(findByCard);

		// find by mileage number
		ConfigurationValue findByMileage = new ConfigurationValue("FindByMileage", true, "Loyalty");
		findByOptions.addChildValue(findByMileage);

		// find by
		ConfigurationValue findByEtk = new ConfigurationValue("FindByETicket", true, "E-Ticket");
		findByOptions.addChildValue(findByEtk);

		// find by PNR
		ConfigurationValue findByPnr = new ConfigurationValue("FindByPnr", true, "PNR");
		findByOptions.addChildValue(findByPnr);

		// find by Confirmation Number
		ConfigurationValue findByConf = new ConfigurationValue("FindByConfirmationNumber", true, "Confirmation Number");
		findByOptions.addChildValue(findByConf);

		// find by Passport
		ConfigurationValue findByPassport = new ConfigurationValue("FindByPassport", true, "Passport");
		findByOptions.addChildValue(findByPassport);

		// find by destination number
		ConfigurationValue findByDestination = new ConfigurationValue("FindByDestination", true, "Destination");
		findByOptions.addChildValue(findByDestination);
	}

	private static void addMileagePlanFunctions(ConfigurationValue screen, ConfigurationValue childScreen) {
		ConfigurationValue mileagePlanFunctions = new ConfigurationValue(ConfigurationKey.FUNCTIONS, true,
				"Mileage Plan");
		childScreen.addChildValue(mileagePlanFunctions);

		// Redress Number
		ConfigurationValue redressNumber = new ConfigurationValue("RedressNumber", true, "Redress Number");
		mileagePlanFunctions.addChildValue(redressNumber);

		// Known Travelers
		ConfigurationValue knownTraveler = new ConfigurationValue("KnownTravelers", true, "Known Travelers");
		mileagePlanFunctions.addChildValue(knownTraveler);

		screen.addChildValue(childScreen);
	}

	private static void addMileagePlanRules(ConfigurationValue screen, ConfigurationValue childScreen) {
		ConfigurationValue mileagePlanRules = new ConfigurationValue(ConfigurationKey.RULES, true, "Mileage Plan");
		childScreen.addChildValue(mileagePlanRules);

		// Mileage Plan Rule
		ConfigurationValue mileagePlanRule = new ConfigurationValue("MileagePlan", true, "Mileage Plan");
		mileagePlanRules.addChildValue(mileagePlanRule);

		String tableName = "MileagePlanTable";

		// /////////////////////////////////////////
		// create the mileage plan table definition
		// ////////////////////////////////////////
		Random randRow = new Random();
		Random randCol = new Random();
		String[] columns = { "A", "B", "C", "D", "E", "F" };

		TableValue mileagePlanTable = new TableValue();
		mileagePlanTable.setKeyName(tableName);

		mileagePlanTable.addColumn("Mileage Plan Program");
		mileagePlanTable.addColumn("Mileage Plan Code");
		mileagePlanTable.addColumn("Allowed For Mileage Credit");
		mileagePlanTable.addColumn("Show Airline Name");

		mileagePlanTable.addRow("Alaska Airlines");
		mileagePlanTable.addRow("American Airlines");
		mileagePlanTable.addRow("British Airlines");
		mileagePlanTable.addRow("Continental Airlines");
		mileagePlanTable.addRow("Delta Airlines");
		mileagePlanTable.addRow("Frontier");
		int row = 0;
		for (Iterator<TableRow> rowIt = mileagePlanTable.getTableRows().iterator(); rowIt.hasNext();) {
			TableRow tableRow = rowIt.next();
			System.out.println("row = " + row);
			int col = 0;
			for (Iterator<TableColumn> colIt = mileagePlanTable.getTableColumns().iterator(); colIt.hasNext();) {
				TableColumn tableColumn = colIt.next();
				System.out.println("col = " + col);
				if (tableColumn.getOrdinal() > 0) {
					if (tableColumn.getOrdinal() == 1) {
						try {
							mileagePlanTable.setValue((int) tableRow.getOrdinal(), (int) tableColumn.getOrdinal(),
									columns[randCol.nextInt(6)] + randRow.nextInt(40));
						} catch (Exception e1) {
							// TODO Auto-generated catch block
							e1.printStackTrace();
						}
					} else {
						try {
							mileagePlanTable
									.setValue((int) tableRow.getOrdinal(), (int) tableColumn.getOrdinal(), true);
						} catch (Exception e) {
							// TODO Auto-generated catch block
							e.printStackTrace();
						}
					}
				}
			}
			row++;
		}

		mileagePlanRule.addChildValue(mileagePlanTable);
		screen.addChildValue(childScreen);
	}

	private static void addGlobalCategoryScreens(ConfigurationValue kiosk) {

		ConfigurationValue category = new ConfigurationValue("Global TESTME", true, "Global");
		kiosk.addChildValue(category);

		// add screens to category
		ConfigurationValue screen = new ConfigurationValue("Logo", true, "Logo");
		category.addChildValue(screen);

		screen = new ConfigurationValue("LanguageOptions", true, "Language Options");
		category.addChildValue(screen);

		screen = new ConfigurationValue("ProgressBars", true, "ProgressBars");
		category.addChildValue(screen);

		// errors screen
		screen = new ConfigurationValue("Errors", true, "Errors");
		category.addChildValue(screen);

		ConfigurationValue childScreen = new ConfigurationValue("GeneralProcessing", true, "General Processing");
		screen.addChildValue(childScreen);

		childScreen = new ConfigurationValue("FindReservation", true, "Find Reservation");
		screen.addChildValue(childScreen);

		childScreen = new ConfigurationValue("PNRValidation", true, "PNR Validation");
		screen.addChildValue(childScreen);

		childScreen = new ConfigurationValue("PassengerSelection", true, "Passenger Selection");
		screen.addChildValue(childScreen);

		childScreen = new ConfigurationValue("AddFFN", true, "Add Frequent Flyer Number");
		screen.addChildValue(childScreen);

		childScreen = new ConfigurationValue("Seats", true, "Seats");
		screen.addChildValue(childScreen);

		childScreen = new ConfigurationValue("Baggage", true, "Baggage");
		screen.addChildValue(childScreen);

		childScreen = new ConfigurationValue("FeesAndPayment", true, "Fees and Payment");
		screen.addChildValue(childScreen);

		childScreen = new ConfigurationValue("InternationalDocs", true, "International Document Collection");
		screen.addChildValue(childScreen);

		childScreen = new ConfigurationValue(
				"Check-In",
				"http://153.71.90.109:8080/application-manager-service/kioskCheck-In?themeUUID=2290af2a-44b8-4c82-b63f-97314aa1d9ef&path=Global&Errors&Check-In",
				"Check-In");
		addCheckInScreenText(childScreen);
		screen.addChildValue(childScreen);
	}
	
	private static void addWebCategoriesAndScreens(ConfigurationValue web) {
		addWebGlobalCategoryScreens(web);
		addBaseAppCategoryScreens(web);
		addInternationalDocumentEntryCategoryScreens(web);
		addFeeModulesCategoryScreens(web);
		addNonRevenueModuleCategoryScreens(web);
	}
	
	private static void addWebGlobalCategoryScreens(ConfigurationValue web) {
		ConfigurationValue category = new ConfigurationValue("Global", true, "Global");
		web.addChildValue(category);
		// Language Options
		ConfigurationValue screen = new ConfigurationValue("LanguageOptions", true, "Language Options");
		category.addChildValue(screen);
		// Progress Bars
		screen = new ConfigurationValue("ProgressBars", true, "Progress Bars");
		category.addChildValue(screen);
		// General Processing
		screen = new ConfigurationValue("GeneralProcessing", true, "General Processing");
		category.addChildValue(screen);
		// Rules
		screen = new ConfigurationValue("Rules", true, "Rules");
		category.addChildValue(screen);
		// Error Messaging
		screen = new ConfigurationValue("ErrorMessaging", true, "Error Messaging");
		category.addChildValue(screen);
		// Flow Options
		screen = new ConfigurationValue("FlowOptions", true, "Flow Options");
		category.addChildValue(screen);
	}

	private static void addBaseAppCategoryScreens(ConfigurationValue web) {
		ConfigurationValue category = new ConfigurationValue("BaseCheckInApp", true, "Base Check-In App");
		web.addChildValue(category);
		// Find By Screen
		ConfigurationValue screen = new ConfigurationValue("FindByOptions", true, "Find By Screen");
		category.addChildValue(screen);

		// Passenger Selection
		screen = new ConfigurationValue("PassengerSelection", true, "Passenger Selection");
		category.addChildValue(screen);
		// (sub screen) Add Mileage Plan
		ConfigurationValue childScreen = new ConfigurationValue("AddMileagePlan", true, "Add Mileage Plan");
		addMileagePlanRules(screen, childScreen);
		screen.addChildValue(childScreen);
		// (sub screen) Add Infant Passenger Selection
		childScreen = new ConfigurationValue("AddInfantPassengerSelection", true, "Add Infant Passenger Selection");
		screen.addChildValue(childScreen);
		// (sub screen) Add Infant Details Screenshot
		childScreen = new ConfigurationValue("AddInfantDetailsScreenshot", true, "Add Infant Details Screenshot");
		screen.addChildValue(childScreen);
		
		// Special Service Requests
		screen = new ConfigurationValue("SpecialServiceRequests", true, "Special Service Requests");
		category.addChildValue(screen);
		// (sub screen) Wheelchair Requests
		childScreen = new ConfigurationValue("WheelchairRequests", true, "Wheelchair Requests");
		screen.addChildValue(childScreen);

		// Secure Flight
		screen = new ConfigurationValue("SecureFlight", true, "Secure Flight");
		category.addChildValue(screen);
		// (sub screen) Secure Flight Data Review
		childScreen = new ConfigurationValue("SecureFlightDataReview", true, "Secure Flight Data Review");
		screen.addChildValue(childScreen);
		// (sub screen) Secure Flight Data Entry
		childScreen = new ConfigurationValue("SecureFlightDataEntry", true, "Secure Flight Data Entry");
		screen.addChildValue(childScreen);
		// (sub screen) Secure Flight Privacy Notice
		childScreen = new ConfigurationValue("SecureFlightPrivacyNotice", true, "Secure Flight Privacy Notice");
		screen.addChildValue(childScreen);
		
		// Seat Assignment
		screen = new ConfigurationValue("SeatAssignment", true, "SeatAssignment");
		category.addChildValue(screen);
		// (sub screen) Base Functionality
		childScreen = new ConfigurationValue("BaseFunctionality", true, "Base Functionality");
		screen.addChildValue(childScreen);
		// (sub screen) Seat Map
		childScreen = new ConfigurationValue("SeatMap", true, "Seat Map");
		addSeatAssignmentSeatMapRules(screen, childScreen);
		screen.addChildValue(childScreen);
		// (sub screen) Exit Row Confirmation
		childScreen = new ConfigurationValue("ExitRowConfirmation", true, "Exit Row Confirmation");
		screen.addChildValue(childScreen);

		// Baggage Check
		screen = new ConfigurationValue("BaggageCheck", true, "Baggage Check");
		category.addChildValue(screen);
		// (sub screen) Base Functionality
		childScreen = new ConfigurationValue("BaseFunctionality", true, "Base Functionality");
		addBaggageCheckBaseFunctionalityRules(screen, childScreen);
		screen.addChildValue(childScreen);
		// (sub screen) Baggage Check - Piece
		childScreen = new ConfigurationValue("BaggageCheckPiece", true, "Baggage Check - Piece");
		screen.addChildValue(childScreen);
		// (sub screen) Baggage Check - Weight
		childScreen = new ConfigurationValue("BaggageCheckWeight", true, "Baggage Check - Weight");
		screen.addChildValue(childScreen);
		// (sub screen) Special Items
		childScreen = new ConfigurationValue("Special Items", true, "Special Items");
		addBaggageCheckSpecialItemsRules(screen, childScreen);
		screen.addChildValue(childScreen);

		// Final Check-in
		screen = new ConfigurationValue("FinalCheckIn", true, "Final Check-in");
		category.addChildValue(screen);
		// (sub screen) Print Ticket Receipt
		childScreen = new ConfigurationValue("PrintTicketReceipt", true, "Print Ticket Receipt");
		addFinalCheckInPrintTicketReceiptRules(screen, childScreen);
		screen.addChildValue(childScreen);
		// (sub screen) Email Ticket Receipt
		childScreen = new ConfigurationValue("EmailTicketReceipt", true, "Email Ticket Receipt");
		addFinalCheckInEmailTicketReceiptRules(screen, childScreen);
		screen.addChildValue(childScreen);
		// (sub screen) Print Boarding Pass
		childScreen = new ConfigurationValue("PrintBoardingPass", true, "Print Boarding Pass");
		addFinalCheckInPrintBoardingPassRules(screen, childScreen);
		screen.addChildValue(childScreen);
		// (sub screen) Email Boarding Pass
		childScreen = new ConfigurationValue("EmailBoardingPass", true, "Email Boarding Pass");
		addFinalCheckInEmailBoardingPassRules(screen, childScreen);
		screen.addChildValue(childScreen);

		// Advice To Passenger
		screen = new ConfigurationValue("AdviceToPassenger", true, "Advice To Passenger");
		category.addChildValue(screen);
		// Info Screens
		screen = new ConfigurationValue("InfoScreens", true, "Info Screens");
		category.addChildValue(screen);
		// (sub screen) Info Screen 1
		childScreen = new ConfigurationValue("InfoScreen-1", true, "Info Screen-1");
		screen.addChildValue(childScreen);
		// (sub screen) Info Screen 2
		childScreen = new ConfigurationValue("InfoScreen-2", true, "Info Screen-2");
		screen.addChildValue(childScreen);
		// (sub screen) Info Screen 3
		childScreen = new ConfigurationValue("InfoScreen-3", true, "Info Screen-3");
		screen.addChildValue(childScreen);
		// (sub screen) Info Screen 4
		childScreen = new ConfigurationValue("InfoScreen-4", true, "Info Screen-4");
		screen.addChildValue(childScreen);
		// (sub screen) Info Screen 5
		childScreen = new ConfigurationValue("InfoScreen-5", true, "Info Screen-5");
		screen.addChildValue(childScreen);

		// Same Day Return Offer
		screen = new ConfigurationValue("SameDayReturnOffer", true, "Same Day Return Offer");
		addSameDayReturnOfferRules(screen);
		category.addChildValue(screen);

		// Same Day Return - Thank
		screen = new ConfigurationValue("SameDayReturnThank", true, "Same Day Return - Thank");
		category.addChildValue(screen);
		// (sub screen) SDR Thank You - Option 1
		childScreen = new ConfigurationValue("SDRThankYou-Option-1", true, "SDR Thank You - Option-1");
		screen.addChildValue(childScreen);
		// (sub screen) SDR Thank You - Step-2
		childScreen = new ConfigurationValue("SDRThankYou-Step-2", true, "SDR Thank You - Step-2");
		screen.addChildValue(childScreen);

		// Re-entry Passenger Selection
		screen = new ConfigurationValue("ReEntryPassengerSelection", true, "ReEntryPassengerSelection");
		category.addChildValue(screen);

		// Re-entry and SDR Trip Selection
		screen = new ConfigurationValue("ReEntryAndSDRTripSelection", true, "Re-entry and SDR Trip Selection");
		category.addChildValue(screen);

		// Contact Information
		screen = new ConfigurationValue("ContactInformation", true, "Contact Information");
		category.addChildValue(screen);
		// (sub screen) Base Functionality
		childScreen = new ConfigurationValue("BaseFunctionality", true, "BaseFunctionality");
		addContactInformationBaseFunctionalityRules(screen, childScreen);
		screen.addChildValue(childScreen);
		// (sub screen) Contact Data Collection
		childScreen = new ConfigurationValue("ContactDataCollection", true, "ContactDataCollection");
		addContactInformationContactDataCollectionRules(screen, childScreen);
		screen.addChildValue(childScreen);

		// Over sold Solicitation
		screen = new ConfigurationValue("OverSoldSolicitation", true, "Over sold Solicitation");
		category.addChildValue(screen);
		// (sub screen) Base Functionality
		childScreen = new ConfigurationValue("BaseFunctionality", true, "BaseFunctionality");
		addOverSoldSolicitationBaseFunctionalityRules(screen, childScreen);
		screen.addChildValue(childScreen);
		// (sub screen) Over sold Advisory Message
		childScreen = new ConfigurationValue("OverSoldAdvisoryMessage", true, "Over sold Advisory Message");
		screen.addChildValue(childScreen);

		// Flight interruption at check-in
		screen = new ConfigurationValue("FlightInterruptionAtCheckIn", true, "Flight interruption at check-in");
		category.addChildValue(screen);
		// (sub screen) Base Functionality
		childScreen = new ConfigurationValue("BaseFunctionality", true, "BaseFunctionality");
		addFlightInterruptionAtCheckInBaseFunctionalityRules(screen, childScreen);
		screen.addChildValue(childScreen);
		// (sub screen) Flight Options
		childScreen = new ConfigurationValue("FlightOptions", true, "Flight Options");
		addFlightInterruptionAtCheckInFlightOptionsRules(screen, childScreen);
		screen.addChildValue(childScreen);
		// (sub screen) Flight Compensation
		childScreen = new ConfigurationValue("FlightCompensation", true, "Flight Compensation");
		addFlightInterruptionAtCheckInFlightCompensationRules(screen, childScreen);
		screen.addChildValue(childScreen);
		// (sub screen) Voucher Printing
		childScreen = new ConfigurationValue("VoucherPrinting", true, "Voucher Printing");
		addFlightInterruptionAtCheckInVoucherPrintingRules(screen, childScreen);
		screen.addChildValue(childScreen);

	}

	private static void addInternationalDocumentEntryCategoryScreens(ConfigurationValue web) {
		ConfigurationValue category = new ConfigurationValue("InternationalDocumentEntry", true,
				"International Document Entry");
		web.addChildValue(category);
		// Base Functionality
		ConfigurationValue screen = new ConfigurationValue("BaseFunctionality", true, "Base Functionality");
		addInternationalDocumentEntryBaseFunctionalityRules(screen);
		category.addChildValue(screen);
		// Passport Data Collection
		screen = new ConfigurationValue("PassportDataCollection", true, "Passport Data Collection");
		category.addChildValue(screen);
		// Resident Card
		screen = new ConfigurationValue("ResidentCard", true, "Resident Card");
		category.addChildValue(screen);
		// Destination Address
		screen = new ConfigurationValue("DestinationAddress", true, "Destination Address");
		addInternationalDocumentEntryDestinationAddressRules(screen);
		category.addChildValue(screen);
		// Emergency Contact
		screen = new ConfigurationValue("EmergencyContact", true, "Emergency Contact");
		addInternationalDocumentEntryEmergencyContactRules(screen);
		category.addChildValue(screen);
		// Information Screens
		screen = new ConfigurationValue("InformationScreens", true, "Information Screens");
		category.addChildValue(screen);
		// (sub screen) Info Screen 1
		ConfigurationValue childScreen = new ConfigurationValue("InfoScreen-1", true, "Info Screen-1");
		screen.addChildValue(childScreen);
		// (sub screen) Info Screen 2
		childScreen = new ConfigurationValue("InfoScreen-2", true, "Info Screen-2");
		screen.addChildValue(childScreen);

	}

	private static void addFeeModulesCategoryScreens(ConfigurationValue web) {
		ConfigurationValue category = new ConfigurationValue("FeeModules", true, "Fee Modules");
		web.addChildValue(category);

		// Fee Review Screen
		ConfigurationValue screen = new ConfigurationValue("FeeReviewScreen", true, "Fee Review Screen");
		category.addChildValue(screen);
		// Payment Options
		screen = new ConfigurationValue("PaymentOptions", true, "Payment Options");
		category.addChildValue(screen);
		// (sub screen) Fee Receipt Printing
		ConfigurationValue childScreen = new ConfigurationValue("FeeReceiptPrinting", true, "Fee Receipt Printing");
		screen.addChildValue(childScreen);

		// Baggage Fee
		screen = new ConfigurationValue("BaggageFee", true, "Baggage Fee");
		category.addChildValue(screen);
		// (sub screen) Baggage Fee - Piece
		childScreen = new ConfigurationValue("BaggageFee-Piece", true, "Baggage Fee - Piece");
		screen.addChildValue(childScreen);
		// (sub screen) FBaggage Fee - Weight
		childScreen = new ConfigurationValue("BaggageFee-Weight", true, "Baggage Fee - Weight");
		screen.addChildValue(childScreen);

		// Change Flight
		screen = new ConfigurationValue("ChangeFlight", true, "Change Flight");
		category.addChildValue(screen);

		// Base Functionality
		screen = new ConfigurationValue("BaseFunctionality", true, "Base Functionality");
		category.addChildValue(screen);
		// (sub screen) Change Flight Selection
		childScreen = new ConfigurationValue("ChangeFlightSelection", true, "Change Flight Selection");
		addFeeModulesBaseFunctionalityChangeFlightSelectionRules(screen, childScreen);
		screen.addChildValue(childScreen);

		// Premium Seating
		screen = new ConfigurationValue("PremiumSeating", true, "Premium Seating");
		category.addChildValue(screen);
		// (sub screen) Premium Seating Seat Map
		childScreen = new ConfigurationValue("PremiumSeatingSeatMap", true, "Premium Seating Seat Map");
		screen.addChildValue(childScreen);
		// (sub screen) Upgrade Offer
		childScreen = new ConfigurationValue("UpgradeOffer", true, "Upgrade Offer");
		addFeeModulesPremiumSeatingUpgradeOfferRules(screen, childScreen);

		screen.addChildValue(childScreen);

	}

	private static void addNonRevenueModuleCategoryScreens(ConfigurationValue web) {
		ConfigurationValue category = new ConfigurationValue("NonRevenueModule", true, "Non Revenue Module");
		web.addChildValue(category);
		// Base Functionality
		ConfigurationValue screen = new ConfigurationValue("BaseFunctionality", true, "Base Functionality");
		category.addChildValue(screen);

		// Find By Options
		screen = new ConfigurationValue("FindByOptions", true, "Find By Options");
		category.addChildValue(screen);
		// (sub screen) NRSA Passenger Processing
		ConfigurationValue childScreen = new ConfigurationValue("NRSAPassengerProcessing", true,
				"NRSA Passenger Processing");

		screen.addChildValue(childScreen);
		// (2nd level sub screen) NRSA Passenger Processing
		ConfigurationValue grandChildScreen = new ConfigurationValue("NRSAPassengerSelection", true,
				"NRSA Passenger Selection");
		addFindByOptionsNRSAPassengerProcessingNRSAPrioritySelection(screen, childScreen, grandChildScreen);
		childScreen.addChildValue(grandChildScreen);
		// (2nd level sub screen) NRSA Priority Selection
		grandChildScreen = new ConfigurationValue("NRSAPrioritySelection", true, "NRSA Priority Selection");
		childScreen.addChildValue(grandChildScreen);
		// (2nd level sub screen) NRPS Thank You Screen
		grandChildScreen = new ConfigurationValue("NRPSThankYouScreen", true, "NRPS Thank You Screen");
		childScreen.addChildValue(grandChildScreen);

		// (sub screen) NRPS Passenger Processing
		childScreen = new ConfigurationValue("NRPSPassengerProcessing", true, "NRPS Passenger Processing");
		screen.addChildValue(childScreen);
		// (2nd level sub screen) Selection
		grandChildScreen = new ConfigurationValue("Selection", true, "Selection");
		childScreen.addChildValue(grandChildScreen);
		// (2nd level sub screen) NRPS Priority Selection
		grandChildScreen = new ConfigurationValue("NRSAPrioritySelection", true, "NRSA Priority Selection");
		addFindByOptionsNRPSPassengerProcessingNRSAPrioritySelection(screen, childScreen, grandChildScreen);
		childScreen.addChildValue(grandChildScreen);
		// (2nd level sub screen) NRPS Thank You Screen
		grandChildScreen = new ConfigurationValue("NRPSThankYouScreen", true, "NRPS Thank You Screen");
		childScreen.addChildValue(grandChildScreen);

		// Payment Options
		screen = new ConfigurationValue("InformationScreens", true, "Information Screens");
		category.addChildValue(screen);
		// (sub screen) Info Screen 1
		childScreen = new ConfigurationValue("InfoScreen-1", true, "Info Screen-1");
		screen.addChildValue(childScreen);
		// (sub screen) Info Screen 2
		childScreen = new ConfigurationValue("InfoScreen-2", true, "Info Screen-2");
		screen.addChildValue(childScreen);

	}

	private static void addSeatAssignmentSeatMapRules(ConfigurationValue screen, ConfigurationValue childScreen) {
		ConfigurationValue seatMapRules = new ConfigurationValue(ConfigurationKey.RULES, true, "Seat Map");
		childScreen.addChildValue(seatMapRules);

		// Seat Map Rule
		ConfigurationValue seatMapRule = new ConfigurationValue("SeatMap", true, "Seat Map");
		seatMapRules.addChildValue(seatMapRule);

		String tableName = "SeatMap";

		TableValue seatMapTable = new TableValue();
		seatMapTable.setKeyName(tableName);

		seatMapTable.addColumn("Seat Map Legend");
		seatMapTable.addColumn("Seat Map Allowed");
		
		seatMapTable.addRow("Preferred Seating");
		seatMapTable.addRow("Your Seat");
		seatMapTable.addRow("Companion Seat");
		seatMapTable.addRow("Available Seat");
		seatMapTable.addRow("Exit Row");
		
		int row = 0;
		for (Iterator<TableRow> rowIt = seatMapTable.getTableRows().iterator(); rowIt.hasNext();) {
			TableRow tableRow = rowIt.next();
			System.out.println("row = " + row);
			int col = 0;
			for (Iterator<TableColumn> colIt = seatMapTable.getTableColumns().iterator(); colIt.hasNext();) {
				TableColumn tableColumn = colIt.next();
				System.out.println("col = " + col);
				if (tableColumn.getOrdinal() > 0) {
					try {
						seatMapTable
								.setValue((int) tableRow.getOrdinal(), (int) tableColumn.getOrdinal(), true);
					} catch (Exception e) {
						// TODO Auto-generated catch block
						e.printStackTrace();
					}
				}
			}
			row++;
		}

		seatMapRule.addChildValue(seatMapTable);
		screen.addChildValue(childScreen);
	}

	private static void addBaggageCheckBaseFunctionalityRules(ConfigurationValue screen, ConfigurationValue childScreen) {

	}

	private static void addBaggageCheckSpecialItemsRules(ConfigurationValue screen, ConfigurationValue childScreen) {

	}

	private static void addFinalCheckInPrintTicketReceiptRules(ConfigurationValue screen, ConfigurationValue childScreen) {

	}

	private static void addFinalCheckInEmailTicketReceiptRules(ConfigurationValue screen, ConfigurationValue childScreen) {

	}

	private static void addFinalCheckInPrintBoardingPassRules(ConfigurationValue screen, ConfigurationValue childScreen) {

	}

	private static void addFinalCheckInEmailBoardingPassRules(ConfigurationValue screen, ConfigurationValue childScreen) {

	}

	private static void addSameDayReturnOfferRules(ConfigurationValue screen) {
		ConfigurationValue sameDayReturnOfferRules = new ConfigurationValue(ConfigurationKey.RULES, true, "Same Day Return Offer");
		screen.addChildValue(sameDayReturnOfferRules);

		// Same Day Return Offer Rule
		ConfigurationValue sameDayReturnOfferRule = new ConfigurationValue("SameDayReturnOffer", true, "Same Day Return Offer");
		sameDayReturnOfferRules.addChildValue(sameDayReturnOfferRule);

		String tableName = "SameDayReturnOffer";

		TableValue sameDayReturnOfferTable = new TableValue();
		sameDayReturnOfferTable.setKeyName(tableName);

		sameDayReturnOfferTable.addColumn("SDR");
		sameDayReturnOfferTable.addColumn("SDR Allowed");
		
		sameDayReturnOfferTable.addRow("Domestic only");
		sameDayReturnOfferTable.addRow("All Travel");
		sameDayReturnOfferTable.addRow("Cabin flown in");
		sameDayReturnOfferTable.addRow("Elite status");
		sameDayReturnOfferTable.addRow("Baggage Check");
		
		int row = 0;
		for (Iterator<TableRow> rowIt = sameDayReturnOfferTable.getTableRows().iterator(); rowIt.hasNext();) {
			TableRow tableRow = rowIt.next();
			System.out.println("row = " + row);
			int col = 0;
			for (Iterator<TableColumn> colIt = sameDayReturnOfferTable.getTableColumns().iterator(); colIt.hasNext();) {
				TableColumn tableColumn = colIt.next();
				System.out.println("col = " + col);
				if (tableColumn.getOrdinal() > 0) {
					try {
						sameDayReturnOfferTable
								.setValue((int) tableRow.getOrdinal(), (int) tableColumn.getOrdinal(), true);
					} catch (Exception e) {
						// TODO Auto-generated catch block
						e.printStackTrace();
					}
				}
			}
			row++;
		}

		sameDayReturnOfferRule.addChildValue(sameDayReturnOfferTable);
	}

	private static void addContactInformationBaseFunctionalityRules(ConfigurationValue screen,
			ConfigurationValue childScreen) {

	}

	private static void addContactInformationContactDataCollectionRules(ConfigurationValue screen,
			ConfigurationValue childScreen) {

	}

	private static void addOverSoldSolicitationBaseFunctionalityRules(ConfigurationValue screen,
			ConfigurationValue childScreen) {

	}

	private static void addFlightInterruptionAtCheckInBaseFunctionalityRules(ConfigurationValue screen,
			ConfigurationValue childScreen) {
		ConfigurationValue sameDayReturnOfferRules = new ConfigurationValue(ConfigurationKey.RULES, true, "Base Functionality");
		childScreen.addChildValue(sameDayReturnOfferRules);

		// Base Functionality Rule
		ConfigurationValue baseFunctionalityRule = new ConfigurationValue("BaseFunctionality", true, "Base Functionality");
		sameDayReturnOfferRules.addChildValue(baseFunctionalityRule);

		String tableName = "BaseFunctionality";

		TableValue baseFunctionalityTable = new TableValue();
		baseFunctionalityTable.setKeyName(tableName);

		baseFunctionalityTable.addColumn("Option");
		baseFunctionalityTable.addColumn("Allowed");
		
		baseFunctionalityTable.addRow("Domestic only travel");
		baseFunctionalityTable.addRow("First Class passenger");
		baseFunctionalityTable.addRow("Elite Level passenger");
		baseFunctionalityTable.addRow("Business Class passenger");
		
		int row = 0;
		for (Iterator<TableRow> rowIt = baseFunctionalityTable.getTableRows().iterator(); rowIt.hasNext();) {
			TableRow tableRow = rowIt.next();
			System.out.println("row = " + row);
			int col = 0;
			for (Iterator<TableColumn> colIt = baseFunctionalityTable.getTableColumns().iterator(); colIt.hasNext();) {
				TableColumn tableColumn = colIt.next();
				System.out.println("col = " + col);
				if (tableColumn.getOrdinal() > 0) {
					try {
						baseFunctionalityTable
								.setValue((int) tableRow.getOrdinal(), (int) tableColumn.getOrdinal(), false);
					} catch (Exception e) {
						// TODO Auto-generated catch block
						e.printStackTrace();
					}
				}
			}
			row++;
		}

		baseFunctionalityRule.addChildValue(baseFunctionalityTable);
		screen.addChildValue(childScreen);


	}

	private static void addFlightInterruptionAtCheckInFlightOptionsRules(ConfigurationValue screen,
			ConfigurationValue childScreen) {

	}

	private static void addFlightInterruptionAtCheckInFlightCompensationRules(ConfigurationValue screen,
			ConfigurationValue childScreen) {

	}

	private static void addFlightInterruptionAtCheckInVoucherPrintingRules(ConfigurationValue screen,
			ConfigurationValue childScreen) {

	}

	private static void addInternationalDocumentEntryBaseFunctionalityRules(ConfigurationValue screen) {

	}

	private static void addInternationalDocumentEntryDestinationAddressRules(ConfigurationValue screen) {

	}

	private static void addInternationalDocumentEntryEmergencyContactRules(ConfigurationValue screen) {

	}

	private static void addFeeModulesBaseFunctionalityChangeFlightSelectionRules(ConfigurationValue screen,
			ConfigurationValue childScreen) {

	}

	private static void addFindByOptionsNRPSPassengerProcessingNRSAPrioritySelection(ConfigurationValue screen,
			ConfigurationValue childScreen) {

	}

	private static void addFeeModulesPremiumSeatingUpgradeOfferRules(ConfigurationValue screen,
			ConfigurationValue childScreen) {

	}

	private static void addFindByOptionsNRSAPassengerProcessingNRSAPrioritySelection(ConfigurationValue screen,
			ConfigurationValue childScreen, ConfigurationValue grandChildScreen) {

	}

	private static void addFindByOptionsNRPSPassengerProcessingNRSAPrioritySelection(ConfigurationValue screen,
			ConfigurationValue childScreen, ConfigurationValue grandChildScreen) {

	}

}
